package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.entity.AccountBindAppInfo;
import cc.mrbird.febs.power.service.IAccountBindAppInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/account-bind-app-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AccountBindAppInfoController {

    private final IAccountBindAppInfoService iAccountBindAppInfoService;

    /**
     * 根据账户获取绑定的应用
     * @param accountId
     * @return
     */
    @GetMapping("/info/{accountId}")
    public R getAppInfoByAccount(@PathVariable("accountId") Integer accountId) {
        return R.ok(iAccountBindAppInfoService.getAppInfoByAccount(accountId));
    }

    /**
     * 修改账户ID绑定系统ID
     * @param accountBindAppInfo
     * @return
     */
    @PutMapping("/AccountByAppInfoEdit")
    public R AccountByAppInfoEdit(AccountBindAppInfo accountBindAppInfo) {
        return R.ok(iAccountBindAppInfoService.updateById(accountBindAppInfo));
    }

    /**
     * 新增账户ID绑定系统ID
     * @param accountBindAppInfo
     * @return
     */
    @PostMapping("/AccountByAppInfoAdd")
    public R AccountByAppInfoAdd(AccountBindAppInfo accountBindAppInfo) {
        return R.ok(iAccountBindAppInfoService.save(accountBindAppInfo));
    }

    /**
     * 根据id删除记录
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R AccountByAppInfoDel(@PathVariable Integer id) {
        return R.ok(iAccountBindAppInfoService.removeById(id));
    }

}
